package cn.fintecher.pangolin.service.business.model.request;

import cn.fintecher.pangolin.common.enums.CasePool;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;

import java.util.Objects;

import static org.elasticsearch.index.query.QueryBuilders.matchPhraseQuery;

/**
 * @Author wangxiangdong
 * @Description 查询共债批次号
 * @Date 2019/10/28 17:10
 **/
@Data
public class CollectionDebtRequest {

    @ApiModelProperty("客户身份证")
    private String certificateNo;

    @ApiModelProperty("委托方ID")
    private String principalId;

    @ApiModelProperty("类型 0-在案 1-历史")
    private CasePool type;

    private String batchNumber;
    
    public BoolQueryBuilder generateQueryBuilder() {
        BoolQueryBuilder qb = QueryBuilders
                .boolQuery();
        if (StringUtils.isNoneBlank(this.certificateNo)) {
            qb.must(matchPhraseQuery("certificateNo.keyword", this.certificateNo));
        }
        return qb;
    }
}
